#!/usr/bin/python3.5

# -*- coding: utf-8 -*-


def binary_search(arr,target):
    k=0
    l=0
    r = len(arr)
    # if arr[l]>=target:
    #     return 0
    while r>l:
        mid = (r+l)//2
        k+=1

        if arr[mid]<target:
            l = mid + 1
        else:
            if mid >0 and arr[mid-1]>=target:
                r = mid
            else:
                print(mid)
                return True
    return False



if __name__ == "__main__":
    n = 100
    a = [1,2,2,3,3,3,3,3,4,6,6,7,8]
    target =1
    print(binary_search(a,target))
